Analysis Of TCS (TATA CONSULTANCY SERVICES)
We will have three dataset i.e.. TCS_stock_action.csv, TCS_stock_history.csv and TCS_stock_info.csv .We will analyze these datasets and try to find out that whether this stocks gives a good return or not.
"TCS_sgtock_history.csv" :-
Data columns (total 8 columns): Column Non-Null Count Dtype
0 Date 4463 non-null datetime64[ns]
1 Open 4463 non-null float64
2 High 4463 non-null float64
3 Low 4463 non-null float64
4 Close 4463 non-null float64
5 Volume 4463 non-null int64
6 Dividends 4463 non-null float64
7 Stock Splits 4463 non-null float64
dtypes: datetime64ns, float64(6), int64(1)
memory usage: 279.1 KB
"TCS_stock_action.csv" :-
Data columns (total 3 columns): Column Non-Null Count Dtype
0 Date 70 non-null object 1 Dividends 70 non-null float64 2 Stock Splits 70 non-null float64 dtypes: float64(2), object(1) memory usage: 1.8+ KB
https://www.kaggle.com/datasets/0e540675cd717ee6d6a0a507a28cc1ca9d90d6b9948544f1f9b1bfffd30a1ab7
Tata Consultancy Services (TCS) is an Indian multinational information technology (IT) services and consulting company headquartered in Mumbai, Maharashtra, India with its largest campus located in Chennai, Tamil Nadu, India. As of February 2021, TCS is the largest IT services company in the world by market capitalisation ($200 billion). It is a subsidiary of the Tata Group and operates in 149 locations across 46 countries.
TCS is the second largest Indian company by market capitalisation and is among the most valuable IT services brands worldwide.In 2015, TCS was ranked 64th overall in the Forbes World's Most Innovative Companies ranking, making it both the highest-ranked IT services company and the top Indian company. As of 2018, it is ranked eleventh on the Fortune India 500 list.In April 2018, TCS became the first Indian IT company to reach 100 billion dollar in market capitalisation and second Indian company ever (after Reliance Industries achieved it in 2007) after its market capitalisation stood at ₹6.793 trillion (equivalent to ₹7.3 trillion or US 100 billion dollar in 2019) on the Bombay Stock Exchange.
In 2016–2017, parent company Tata Sons owned 72.05% of TCS and more than 70% of Tata Sons' dividends were generated by TCS. In March 2018, Tata Sons decided to sell stocks of TCS worth 1.25 billion dollar in a bulk deal.As of 15 September 2021, TCS has recorded a market capitalisation of US$200 billion, making it the first Indian IT firm to do so.
The main aim of our project is to analyse the price of 'TCS' throughout the years and on basis of those we will predict future behaviour of this stock. On the basis of price and volume we try to find whether investors are likely to be more interested.
• TCS Datasets.
• Jupyter Notebook or Google collab to perform Queries.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.graph_objects as go
import datetime as dt
# import yfinance
# import mplfinance as mpl
info=pd.read_csv("TCS_stock_info.csv")
info_df=pd.DataFrame(info)
info_df
| zip | 400001 | |
|---|---|---|
| 0 | sector | Technology |
| 1 | fullTimeEmployees | 509058 |
| 2 | longBusinessSummary | Tata Consultancy Services Limited provides inf... |
| 3 | city | Mumbai |
| 4 | phone | 91 22 6778 9999 |
| ... | ... | ... |
| 145 | dividendYield | 0.0105 |
| 146 | bidSize | 0 |
| 147 | dayHigh | 3805 |
| 148 | regularMarketPrice | 3773.2 |
| 149 | logo_url | https://logo.clearbit.com/tcs.com |
150 rows × 2 columns
action=pd.read_csv("TCS_stock_action.csv")
action_df=pd.DataFrame(action)
action_df
| Date | Dividends | Stock Splits | |
|---|---|---|---|
| 0 | 2004-10-28 | 0.3750 | 0.0 |
| 1 | 2005-02-03 | 0.4375 | 0.0 |
| 2 | 2005-07-06 | 0.6250 | 0.0 |
| 3 | 2005-08-18 | 0.3750 | 0.0 |
| 4 | 2005-10-18 | 0.3750 | 0.0 |
| ... | ... | ... | ... |
| 65 | 2020-07-16 | 5.0000 | 0.0 |
| 66 | 2020-10-14 | 12.0000 | 0.0 |
| 67 | 2021-01-14 | 6.0000 | 0.0 |
| 68 | 2021-05-25 | 15.0000 | 0.0 |
| 69 | 2021-07-15 | 7.0000 | 0.0 |
70 rows × 3 columns
tcs=pd.read_csv("TCS_stock_history.csv")
df=pd.DataFrame(tcs)
df
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | |
|---|---|---|---|---|---|---|---|---|
| 0 | 2002-08-12 | 28.794172 | 29.742206 | 28.794172 | 29.519140 | 212976 | 0.0 | 0.0 |
| 1 | 2002-08-13 | 29.556316 | 30.030333 | 28.905705 | 29.119476 | 153576 | 0.0 | 0.0 |
| 2 | 2002-08-14 | 29.184536 | 29.184536 | 26.563503 | 27.111877 | 822776 | 0.0 | 0.0 |
| 3 | 2002-08-15 | 27.111877 | 27.111877 | 27.111877 | 27.111877 | 0 | 0.0 | 0.0 |
| 4 | 2002-08-16 | 26.972458 | 28.255089 | 26.582090 | 27.046812 | 811856 | 0.0 | 0.0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 4458 | 2021-09-24 | 3890.000000 | 3944.399902 | 3855.000000 | 3871.300049 | 2320754 | 0.0 | 0.0 |
| 4459 | 2021-09-27 | 3900.000000 | 3904.000000 | 3802.899902 | 3836.949951 | 1673362 | 0.0 | 0.0 |
| 4460 | 2021-09-28 | 3850.000000 | 3850.000000 | 3751.250000 | 3779.149902 | 2253075 | 0.0 | 0.0 |
| 4461 | 2021-09-29 | 3759.800049 | 3806.000000 | 3722.149902 | 3791.899902 | 2489161 | 0.0 | 0.0 |
| 4462 | 2021-09-30 | 3805.000000 | 3805.000000 | 3765.000000 | 3773.199951 | 640479 | 0.0 | 0.0 |
4463 rows × 8 columns
df.describe()
| Open | High | Low | Close | Volume | Dividends | Stock Splits | |
|---|---|---|---|---|---|---|---|
| count | 4463.000000 | 4463.000000 | 4463.000000 | 4463.000000 | 4.463000e+03 | 4463.000000 | 4463.000000 |
| mean | 866.936239 | 876.675013 | 856.653850 | 866.537398 | 3.537876e+06 | 0.071533 | 0.001344 |
| std | 829.905368 | 838.267104 | 821.233477 | 829.611313 | 3.273531e+06 | 0.965401 | 0.051842 |
| min | 24.146938 | 27.102587 | 24.146938 | 26.377609 | 0.000000e+00 | 0.000000 | 0.000000 |
| 25% | 188.951782 | 191.571816 | 185.979417 | 188.594620 | 1.860959e+06 | 0.000000 | 0.000000 |
| 50% | 530.907530 | 534.751639 | 525.616849 | 529.713257 | 2.757742e+06 | 0.000000 | 0.000000 |
| 75% | 1156.462421 | 1165.815854 | 1143.622800 | 1154.784851 | 4.278625e+06 | 0.000000 | 0.000000 |
| max | 3930.000000 | 3981.750000 | 3892.100098 | 3954.550049 | 8.806715e+07 | 40.000000 | 2.000000 |
print(np.ndim(df))
2
print(np.shape(df))
(4463, 8)
print(type(df))
<class 'pandas.core.frame.DataFrame'>
print(df.dtypes)
Date object Open float64 High float64 Low float64 Close float64 Volume int64 Dividends float64 Stock Splits float64 dtype: object
df.head()
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | MA50 | MA200 | Day | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2002-08-12 | 28.794172 | 29.742206 | 28.794172 | 29.519140 | 212976 | 0.0 | 0.0 | 2002 | 6.132468e+06 | NaN | NaN | 12 |
| 1 | 2002-08-13 | 29.556316 | 30.030333 | 28.905705 | 29.119476 | 153576 | 0.0 | 0.0 | 2002 | 4.539141e+06 | NaN | NaN | 13 |
| 2 | 2002-08-14 | 29.184536 | 29.184536 | 26.563503 | 27.111877 | 822776 | 0.0 | 0.0 | 2002 | 2.401234e+07 | NaN | NaN | 14 |
| 3 | 2002-08-15 | 27.111877 | 27.111877 | 27.111877 | 27.111877 | 0 | 0.0 | 0.0 | 2002 | 0.000000e+00 | NaN | NaN | 15 |
| 4 | 2002-08-16 | 26.972458 | 28.255089 | 26.582090 | 27.046812 | 811856 | 0.0 | 0.0 | 2002 | 2.189775e+07 | NaN | NaN | 16 |
df.tail()
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | MA50 | MA200 | Day | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4458 | 2021-09-24 | 3890.000000 | 3944.399902 | 3855.000000 | 3871.300049 | 2320754 | 0.0 | 0.0 | 2021 | 9.027733e+09 | 3525.432206 | 3206.583182 | 24 |
| 4459 | 2021-09-27 | 3900.000000 | 3904.000000 | 3802.899902 | 3836.949951 | 1673362 | 0.0 | 0.0 | 2021 | 6.526112e+09 | 3539.831006 | 3212.650094 | 27 |
| 4460 | 2021-09-28 | 3850.000000 | 3850.000000 | 3751.250000 | 3779.149902 | 2253075 | 0.0 | 0.0 | 2021 | 8.674339e+09 | 3552.279004 | 3218.446193 | 28 |
| 4461 | 2021-09-29 | 3759.800049 | 3806.000000 | 3722.149902 | 3791.899902 | 2489161 | 0.0 | 0.0 | 2021 | 9.358748e+09 | 3563.215005 | 3223.667407 | 29 |
| 4462 | 2021-09-30 | 3805.000000 | 3805.000000 | 3765.000000 | 3773.199951 | 640479 | 0.0 | 0.0 | 2021 | 2.437023e+09 | 3575.715005 | 3228.742965 | 30 |
df.columns
Index(['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Dividends',
'Stock Splits'],
dtype='object')
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 4463 entries, 0 to 4462 Data columns (total 8 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Date 4463 non-null object 1 Open 4463 non-null float64 2 High 4463 non-null float64 3 Low 4463 non-null float64 4 Close 4463 non-null float64 5 Volume 4463 non-null int64 6 Dividends 4463 non-null float64 7 Stock Splits 4463 non-null float64 dtypes: float64(6), int64(1), object(1) memory usage: 279.1+ KB
df.Date=pd.to_datetime(df.Date)
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 4463 entries, 0 to 4462 Data columns (total 8 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Date 4463 non-null datetime64[ns] 1 Open 4463 non-null float64 2 High 4463 non-null float64 3 Low 4463 non-null float64 4 Close 4463 non-null float64 5 Volume 4463 non-null int64 6 Dividends 4463 non-null float64 7 Stock Splits 4463 non-null float64 dtypes: datetime64[ns](1), float64(6), int64(1) memory usage: 279.1 KB
df.tail()
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | |
|---|---|---|---|---|---|---|---|---|
| 4458 | 2021-09-24 | 3890.000000 | 3944.399902 | 3855.000000 | 3871.300049 | 2320754 | 0.0 | 0.0 |
| 4459 | 2021-09-27 | 3900.000000 | 3904.000000 | 3802.899902 | 3836.949951 | 1673362 | 0.0 | 0.0 |
| 4460 | 2021-09-28 | 3850.000000 | 3850.000000 | 3751.250000 | 3779.149902 | 2253075 | 0.0 | 0.0 |
| 4461 | 2021-09-29 | 3759.800049 | 3806.000000 | 3722.149902 | 3791.899902 | 2489161 | 0.0 | 0.0 |
| 4462 | 2021-09-30 | 3805.000000 | 3805.000000 | 3765.000000 | 3773.199951 | 640479 | 0.0 | 0.0 |
null_count=df.isnull().sum().sum()
print("Total Null Values:",null_count)
Total Null Values: 0
df['year'] = pd.DatetimeIndex(df['Date']).year
df.head()
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 2002-08-12 | 28.794172 | 29.742206 | 28.794172 | 29.519140 | 212976 | 0.0 | 0.0 | 2002 |
| 1 | 2002-08-13 | 29.556316 | 30.030333 | 28.905705 | 29.119476 | 153576 | 0.0 | 0.0 | 2002 |
| 2 | 2002-08-14 | 29.184536 | 29.184536 | 26.563503 | 27.111877 | 822776 | 0.0 | 0.0 | 2002 |
| 3 | 2002-08-15 | 27.111877 | 27.111877 | 27.111877 | 27.111877 | 0 | 0.0 | 0.0 | 2002 |
| 4 | 2002-08-16 | 26.972458 | 28.255089 | 26.582090 | 27.046812 | 811856 | 0.0 | 0.0 | 2002 |
fig=go.Figure(data=go.Scatter(x=df['Date'],y=df['Close']))
fig.show()
px.scatter(df,x='Open',y='Close',color='High',size="Volume")
df['MarketCap'] = df['Open'] * df['Volume']
df
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2002-08-12 | 28.794172 | 29.742206 | 28.794172 | 29.519140 | 212976 | 0.0 | 0.0 | 2002 | 6.132468e+06 |
| 1 | 2002-08-13 | 29.556316 | 30.030333 | 28.905705 | 29.119476 | 153576 | 0.0 | 0.0 | 2002 | 4.539141e+06 |
| 2 | 2002-08-14 | 29.184536 | 29.184536 | 26.563503 | 27.111877 | 822776 | 0.0 | 0.0 | 2002 | 2.401234e+07 |
| 3 | 2002-08-15 | 27.111877 | 27.111877 | 27.111877 | 27.111877 | 0 | 0.0 | 0.0 | 2002 | 0.000000e+00 |
| 4 | 2002-08-16 | 26.972458 | 28.255089 | 26.582090 | 27.046812 | 811856 | 0.0 | 0.0 | 2002 | 2.189775e+07 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 4458 | 2021-09-24 | 3890.000000 | 3944.399902 | 3855.000000 | 3871.300049 | 2320754 | 0.0 | 0.0 | 2021 | 9.027733e+09 |
| 4459 | 2021-09-27 | 3900.000000 | 3904.000000 | 3802.899902 | 3836.949951 | 1673362 | 0.0 | 0.0 | 2021 | 6.526112e+09 |
| 4460 | 2021-09-28 | 3850.000000 | 3850.000000 | 3751.250000 | 3779.149902 | 2253075 | 0.0 | 0.0 | 2021 | 8.674339e+09 |
| 4461 | 2021-09-29 | 3759.800049 | 3806.000000 | 3722.149902 | 3791.899902 | 2489161 | 0.0 | 0.0 | 2021 | 9.358748e+09 |
| 4462 | 2021-09-30 | 3805.000000 | 3805.000000 | 3765.000000 | 3773.199951 | 640479 | 0.0 | 0.0 | 2021 | 2.437023e+09 |
4463 rows × 10 columns
px.scatter(df,x='year',y='MarketCap',color='year')
Moving Averages
As we know the stock prices are highly volatile and prices change quickly with time. To observe any trend or pattern we can take the help of a 50-day 200-day average
df['MA50'] = df['Open'].rolling(50).mean()
df['MA200'] = df['Open'].rolling(200).mean()
df['Open'].plot(figsize = (20,10))
df['MA50'].plot()
df['MA200'].plot()
<AxesSubplot: >
px.histogram(df,x='Volume',color="year",barmode="group")
px.box(df,y="High")
px.box(df,y="Open")
px.box(df,y="Close")
df1=df[df["year"]==2020]
df1['Month'] = pd.DatetimeIndex(df1['Date']).month_name()
df1.tail()
C:\Users\Dell\AppData\Local\Temp\ipykernel_13040\2410078670.py:2: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | MA50 | MA200 | Month | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4273 | 2020-12-24 | 2883.049754 | 2895.289680 | 2857.479859 | 2883.396729 | 1807144 | 0.0 | 0.0 | 2020 | 5.210086e+09 | 2704.686069 | 2240.879458 | December |
| 4274 | 2020-12-28 | 2884.040737 | 2923.386536 | 2876.112102 | 2903.267578 | 2108994 | 0.0 | 0.0 | 2020 | 6.082425e+09 | 2706.033939 | 2245.075523 | December |
| 4275 | 2020-12-29 | 2893.951334 | 2925.665869 | 2893.951334 | 2904.357666 | 1994151 | 0.0 | 0.0 | 2020 | 5.770976e+09 | 2708.194486 | 2249.433227 | December |
| 4276 | 2020-12-30 | 2908.222868 | 2921.404270 | 2876.111997 | 2883.346924 | 2637968 | 0.0 | 0.0 | 2020 | 7.671799e+09 | 2711.847599 | 2254.554294 | December |
| 4277 | 2020-12-31 | 2874.129861 | 2879.085257 | 2819.620501 | 2837.212158 | 4040956 | 0.0 | 0.0 | 2020 | 1.161423e+10 | 2714.345122 | 2259.646221 | December |
fig=go.Figure(data=go.Scatter(x=df1['Date'],y=df1['High']))
fig.show()
max_price=max(df1['High'])
max_price
2925.665869332239
min_price=min(df1['Low'])
min_price
1467.8803591696203
fig = go.Figure()
fig.add_trace(go.Scatter(x=df1["Date"], y=df1["High"],
mode='lines',
name='High'))
fig.add_trace(go.Scatter(x=df1["Date"], y=df1["Low"],
mode='lines',
name='Low'))
fig.show()
fig1 = go.Figure()
fig1.add_trace(go.Scatter(x=df1["Date"], y=df1["Open"],
mode='lines', name='Open'))
fig1.add_trace(go.Scatter(x=df1["Date"], y=df1["Close"],
mode='lines', name='Close'))
fig1.show()
px.histogram(df1,x='Volume',color="Month",barmode="group")
df1['MA50'] = df1['Open'].rolling(50).mean()
df1['MA200'] = df1['Open'].rolling(200).mean()
df1['Open'].plot(figsize = (20,10))
df1['MA50'].plot()
df1['MA200'].plot()
C:\Users\Dell\AppData\Local\Temp\ipykernel_13040\2359836275.py:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy C:\Users\Dell\AppData\Local\Temp\ipykernel_13040\2359836275.py:2: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
<AxesSubplot: >
px.scatter_matrix(df1,dimensions=["Open","Close","High","Low","Volume"],color="Month")
len(df)
4463
df['Day'] = pd.DatetimeIndex(df['Date']).day
df.tail()
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | MA50 | MA200 | Day | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4458 | 2021-09-24 | 3890.000000 | 3944.399902 | 3855.000000 | 3871.300049 | 2320754 | 0.0 | 0.0 | 2021 | 9.027733e+09 | 3525.432206 | 3206.583182 | 24 |
| 4459 | 2021-09-27 | 3900.000000 | 3904.000000 | 3802.899902 | 3836.949951 | 1673362 | 0.0 | 0.0 | 2021 | 6.526112e+09 | 3539.831006 | 3212.650094 | 27 |
| 4460 | 2021-09-28 | 3850.000000 | 3850.000000 | 3751.250000 | 3779.149902 | 2253075 | 0.0 | 0.0 | 2021 | 8.674339e+09 | 3552.279004 | 3218.446193 | 28 |
| 4461 | 2021-09-29 | 3759.800049 | 3806.000000 | 3722.149902 | 3791.899902 | 2489161 | 0.0 | 0.0 | 2021 | 9.358748e+09 | 3563.215005 | 3223.667407 | 29 |
| 4462 | 2021-09-30 | 3805.000000 | 3805.000000 | 3765.000000 | 3773.199951 | 640479 | 0.0 | 0.0 | 2021 | 2.437023e+09 | 3575.715005 | 3228.742965 | 30 |
#Here we are calculating ROI(Return on investment) from start to end
sumTCS=0 #total amount invested in TCS
s1=0 #number of shares owned by TCS
#calcuating total amount invested and number of shares owned in TCS
for i in range(len(df)):
if df.loc[i,'Day']==30:
sumTCS+=df.loc[i,'Open']
s1+=1
#displaying basic results
print("Total Invested in TCS = Rs",round(sumTCS,2))
print("Shares Owned of TCS =",s1)
print("Average Investmentment of 1 share = Rs",round((sumTCS/s1),2))
TCS_end=3805 #last open price of TCS on 2021-09-30
#calculating investment results
result1=round((TCS_end*s1)-sumTCS,2)
ROI_TCS=round((result1/sumTCS)*100,2)
#displaying investment results
print("\nInvestment Result:")
if result1<0:
print("Net Unrealised Loss = Rs",result1)
else:
print("Net Unrealised Profit = Rs",result1)
print("TCS ROI from 2000-1-3 to 2021-04-30 =",ROI_TCS,"%")
Total Invested in TCS = Rs 124202.71 Shares Owned of TCS = 138 Average Investmentment of 1 share = Rs 900.02 Investment Result: Net Unrealised Profit = Rs 400887.29 TCS ROI from 2000-1-3 to 2021-04-30 = 322.77 %
df1
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | MA50 | MA200 | Month | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4028 | 2020-01-01 | 2108.266570 | 2123.728393 | 2094.652302 | 2107.877686 | 1354908 | 0.0 | 0.0 | 2020 | 2.856507e+09 | NaN | NaN | January |
| 4029 | 2020-01-02 | 2119.886798 | 2119.886798 | 2089.984038 | 2098.201172 | 2380752 | 0.0 | 0.0 | 2020 | 5.046925e+09 | NaN | NaN | January |
| 4030 | 2020-01-03 | 2104.376494 | 2161.750899 | 2104.376494 | 2140.016602 | 4655761 | 0.0 | 0.0 | 2020 | 9.797474e+09 | NaN | NaN | January |
| 4031 | 2020-01-06 | 2144.246950 | 2164.619679 | 2127.618001 | 2139.822266 | 3023209 | 0.0 | 0.0 | 2020 | 6.482507e+09 | NaN | NaN | January |
| 4032 | 2020-01-07 | 2139.870310 | 2153.630344 | 2123.630487 | 2145.072998 | 2429317 | 0.0 | 0.0 | 2020 | 5.198423e+09 | NaN | NaN | January |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 4273 | 2020-12-24 | 2883.049754 | 2895.289680 | 2857.479859 | 2883.396729 | 1807144 | 0.0 | 0.0 | 2020 | 5.210086e+09 | 2704.686069 | 2240.879458 | December |
| 4274 | 2020-12-28 | 2884.040737 | 2923.386536 | 2876.112102 | 2903.267578 | 2108994 | 0.0 | 0.0 | 2020 | 6.082425e+09 | 2706.033939 | 2245.075523 | December |
| 4275 | 2020-12-29 | 2893.951334 | 2925.665869 | 2893.951334 | 2904.357666 | 1994151 | 0.0 | 0.0 | 2020 | 5.770976e+09 | 2708.194486 | 2249.433227 | December |
| 4276 | 2020-12-30 | 2908.222868 | 2921.404270 | 2876.111997 | 2883.346924 | 2637968 | 0.0 | 0.0 | 2020 | 7.671799e+09 | 2711.847599 | 2254.554294 | December |
| 4277 | 2020-12-31 | 2874.129861 | 2879.085257 | 2819.620501 | 2837.212158 | 4040956 | 0.0 | 0.0 | 2020 | 1.161423e+10 | 2714.345122 | 2259.646221 | December |
250 rows × 13 columns
#finding ROI in covid time
sumTCS1=0 #total amount invested in TCS during covid time
s2=0 #number of shares owned by TCS
#calcuating total amount invested and number of shares owned in TCS
for i in range(4028,4278):
if df.loc[i,'Day']==30:
sumTCS1+=df.loc[i,'Open']
s2+=1
#displaying basic results
print("Total Invested in TCS = Rs",round(sumTCS1,2))
print("Shares Owned of TCS =",s2)
print("Average Investmentment of 1 share = Rs",round((sumTCS1/s2),2))
TCS_end=2874.12 #last open price of TCS on 2020-12-31
#calculating investment results
result2=round((TCS_end*s2)-sumTCS1,2)
ROI_TCS1=round((result2/sumTCS1)*100,2)
#displaying investment results
print("\nInvestment Result:")
if result2<0:
print("Net Unrealised Loss = Rs",result2)
else:
print("Net Unrealised Profit = Rs",result2)
print("TCS ROI from 2020-1-1 to 2020-12-31 =",ROI_TCS1,"%")
Total Invested in TCS = Rs 18083.81 Shares Owned of TCS = 8 Average Investmentment of 1 share = Rs 2260.48 Investment Result: Net Unrealised Profit = Rs 4909.15 TCS ROI from 2020-1-1 to 2020-12-31 = 27.15 %
df2=df[df["year"]==2012]
df2['Month'] = pd.DatetimeIndex(df2['Date']).month_name()
df2
C:\Users\Dell\AppData\Local\Temp\ipykernel_13040\3432205665.py:2: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
| Date | Open | High | Low | Close | Volume | Dividends | Stock Splits | year | MarketCap | MA50 | MA200 | Day | Month | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2063 | 2012-01-02 | 479.765471 | 490.075656 | 476.459593 | 487.038391 | 2248542 | 0.0 | 0.0 | 2012 | 1.078773e+09 | 464.288172 | 457.068325 | 2 | January |
| 2064 | 2012-01-03 | 488.959984 | 499.972700 | 487.616972 | 494.889893 | 2708884 | 0.0 | 0.0 | 2012 | 1.324536e+09 | 465.314653 | 457.267911 | 3 | January |
| 2065 | 2012-01-04 | 497.906595 | 497.947909 | 483.195447 | 484.724396 | 2386770 | 0.0 | 0.0 | 2012 | 1.188389e+09 | 466.676658 | 457.571421 | 4 | January |
| 2066 | 2012-01-05 | 484.641643 | 489.683086 | 482.389484 | 484.311035 | 2547312 | 0.0 | 0.0 | 2012 | 1.234533e+09 | 467.831059 | 457.800442 | 5 | January |
| 2067 | 2012-01-06 | 481.831625 | 491.067410 | 478.029887 | 483.236633 | 2119728 | 0.0 | 0.0 | 2012 | 1.021352e+09 | 468.773488 | 457.980715 | 6 | January |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2303 | 2012-12-24 | 528.812311 | 532.625448 | 528.016149 | 530.572205 | 1254818 | 0.0 | 0.0 | 2012 | 6.635632e+08 | 539.583990 | 521.500739 | 24 | December |
| 2304 | 2012-12-26 | 530.907530 | 531.808449 | 526.004932 | 528.896179 | 1435258 | 0.0 | 0.0 | 2012 | 7.619893e+08 | 539.349917 | 521.621364 | 26 | December |
| 2305 | 2012-12-27 | 530.027528 | 530.027528 | 522.799309 | 524.182068 | 1994158 | 0.0 | 0.0 | 2012 | 1.056959e+09 | 539.197740 | 521.731373 | 27 | December |
| 2306 | 2012-12-28 | 525.460258 | 533.002749 | 524.098419 | 531.117126 | 1501622 | 0.0 | 0.0 | 2012 | 7.890427e+08 | 538.918684 | 521.843408 | 28 | December |
| 2307 | 2012-12-31 | 528.393107 | 530.320621 | 524.621864 | 526.235107 | 704170 | 0.0 | 0.0 | 2012 | 3.720786e+08 | 538.794025 | 521.992900 | 31 | December |
245 rows × 14 columns
#finding ROI in 2012
sumTCS2=0 #total amount invested in TCS during 2012
s3=0 #number of shares owned by TCS
#calcuating total amount invested and number of shares owned in TCS
for i in range(2063,2308):
if df.loc[i,'Day']==30:
sumTCS2+=df.loc[i,'Open']
s3+=1
#displaying basic results
print("Total Invested in TCS = Rs",round(sumTCS2,2))
print("Shares Owned of TCS =",s3)
print("Average Investmentment of 1 share = Rs",round((sumTCS2/s3),2))
TCS_end=528.39 #last open price of TCS on 2012-12-31
#calculating investment results
result3=round((TCS_end*s3)-sumTCS2,2)
ROI_TCS2=round((result3/sumTCS2)*100,2)
#displaying investment results
print("\nInvestment Result:")
if result3<0:
print("Net Unrealised Loss = Rs",result3)
else:
print("Net Unrealised Profit = Rs",result3)
print("TCS ROI from 2012-1-1 to 2012-12-31 =",ROI_TCS2,"%")
Total Invested in TCS = Rs 4105.04 Shares Owned of TCS = 8 Average Investmentment of 1 share = Rs 513.13 Investment Result: Net Unrealised Profit = Rs 122.08 TCS ROI from 2012-1-1 to 2012-12-31 = 2.97 %
plt.figure(figsize=(20,10))
year=['2002-2021','2012','2020']
ROI=[ROI_TCS,ROI_TCS2,ROI_TCS1]
col=['Blue','Grey','Orange']
plt.bar(year,ROI,color=col)
plt.title("ROI")
plt.xlabel("Time")
plt.ylabel("Percentage")
Text(0, 0.5, 'Percentage')
plt.figure(figsize=(20,10))
stock=['2002-2021','2012','2020']
result=[result1,result3,result2]
col=['Blue','Grey','Orange']
plt.pie(result,labels=stock,autopct="%1.2f%%",colors=col)
plt.legend(title="",loc="upper left")
plt.title("Realised Profit")
Text(0.5, 1.0, 'Realised Profit')
*Conclusion*:
This is NOT FINANCIAL ADVICE, and all work done in this project is for educational purposes only. This analysis depicts a stock’s long-term performance,and int covid time and shows the potential of SIP in the long run.
During our visualization we can say that share price of tcs will go on increasing untill and unless some big fundamental factors caused some problems.
But due to high demand and increasing interest in tech field chances of this stock giving good returns is excellent because it survived through the covid and gave a good return.